package com.yang.subjectservice.utils;

import com.alibaba.excel.EasyExcel;
import com.yang.subjectservice.excel.StudentExcelDemo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yds
 * @program edu
 * @description excel工具类
 * @create 2020-11-27 16:50
 **/
public class ExcelUtils {
    public static void main(String[] args) {
        String fileName="C:\\zip\\student.xlsx";
        EasyExcel.write(fileName, StudentExcelDemo.class).sheet("学生列表").doWrite(getData());

    }

    private static List<StudentExcelDemo> getData(){
        List<StudentExcelDemo> list=new ArrayList<StudentExcelDemo>();
        for (int i=0;i<10;i++){
         StudentExcelDemo demo=new StudentExcelDemo();
         demo.setSno(i);
         demo.setSname("lucy"+i);
         list.add(demo);
        }
        return list;
    }

}
